/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once

#include "UI/Widget.h"
#include "UI/ui绘制模板.h"



#include <string>
#include <map>




class C_菜单项;

typedef void(*fp_on_菜单项点击)(struct C_Widget* self, const std::wstring, uint16 id);


class C_菜单 : public C_Widget {
	uint32		ui_当前菜单项;
	C_Widget*	ui_Root菜单项;
	C_Widget*	ui_弹出窗口;

public:
	C_菜单(E_方向 dir, S_UI创建环境& ctx);
	~C_菜单();

	uint32				m_layer;
	const E_方向		m_排列方向;
	

	ui_绘制模板_画预设图形 m_背景绘制;
	ui_绘制模板_画预设图形 m_分隔线绘制;
	//ui_绘制模板_行文本绘制			m_字符绘制;


	static C_菜单* m_当前打开菜单;


	void f_打开(const vec2& pos, const bool 记忆 = false);
	void f_关闭();

	C_菜单项* f_添加项(const std::wstring txt, std::string ico="");
	void      f_移除项(C_菜单项* itme);
	void      f_设置项冻结(uint32 id, bool y);

};










class C_菜单项 : public C_Widget {
	//C_Widget*	ui_根菜单;
public:
	C_菜单项(S_UI创建环境& ctx, const std::wstring txt, const std::string& ico, float32 菜单厚度 = 20);

	ui_绘制模板_画预设图形	m_背景绘制;
	ui_绘制模板_行文本绘制	m_字符绘制;
	ui_绘制模板_图标		m_图标绘制;

	std::wstring        m_标题;
	std::string			m_图标;
	bool				m_是否获取焦点;
	C_菜单*				ui_子菜单;
	fp_on_菜单项点击	mf_菜单事件;

	inline std::wstring		f_getTitle() { return m_标题; }
	
	C_菜单* f_添加子菜单(uint32 layer, S_UI创建环境& ctx);

protected:
	void f_关闭菜单链(C_Widget* w);
};















//struct S_菜单项创建参数;
class S_菜单项创建参数 {
public:
	std::wstring		name;
	std::string			ico;

	void* 子菜单参数;
};

struct S_菜单创建参数 {
	fp_on_菜单项点击 mf_菜单项点击;
	std::vector<S_菜单项创建参数> item;
};






vec2 f_菜单子项坐标矫正(C_菜单项* 项);
vec2 f_菜单坐标矫正(C_菜单* 项, vec2 pos);





//void f_顶层菜单画布构建(C_菜单* self, uint32 layer, S_UI创建环境& ctx);
